import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false
//引入路由
import router from '@/router'
import TypeNav from '@/components/TypeNav'//商品类别导航
import Carousel from '@/components/Carousel'//轮播图
import Pagination from '@/components/Pagination'//分页器
import {MessageBox} from 'element-ui'
//注册全局组件，方便使用
Vue.component(TypeNav.name, TypeNav)
Vue.component(Carousel.name, Carousel)
Vue.component(Pagination.name, Pagination)
Vue.prototype.$msgbox = MessageBox
Vue.prototype.$alert = MessageBox.alert
//引入仓库
import store from "@/store";
//引入mock，来进行数据模拟
import '@/mock/mockServe.js'
//引入swiper样式，用于轮播图
import 'swiper/css/swiper.css'

//引入插件
import VueLazyload from 'vue-lazyload'
import loadingImg from '@/assets/loadingImg.jpg'
import VeeValidate from "vee-validate"
import zh_CN from 'vee-validate/dist/locale/zh_CN'

Vue.use(VueLazyload, {
    loading: loadingImg
})
Vue.use(VeeValidate)
//表单验证
VeeValidate.Validator.localize('zh_CN', {
    messages: {
        ...zh_CN.messages,
        //用于校验是否相等
        is: (field) => `${field}必须与密码相同`,
    },
    attributes: {
        //校验字段的中文名称
        phoneNumber: '手机号',
        inputVerificationCode: '验证码',
        password: '密码',
        passwordConfirm: '确认密码',
        isAgree: '协议'
    }
})
//自定义校验规则
VeeValidate.Validator.extend('isAgree', {
        validate: (value) => value,
        getMessage: (field) => `${field}必须同意`
    }
)

new Vue({
    render: h => h(App),
    router,
    store,
    //配置全局事件总线
    beforeCreate() {
        Vue.prototype.$bus = this
    }
}).$mount('#app')
